import java.util.Arrays;

public class MyStack {
    private int[] elem = new int[DEFAULT_CAPACITI];
    private int usedSize;
    private static final int DEFAULT_CAPACITI = 10;
    public MyStack(int[] elem) {
        this.elem = elem;
    }
    public void push(int val){
        if(ifFull()){
            elem = Arrays.copyOf(elem,2*elem.length);
        }
        this.elem[usedSize] = val;
        usedSize++;
    }
    public boolean ifFull(){
        return usedSize == elem.length;
    }
    public int pop(){
        if(isEmpty()){
            throw new EmptuException("没有元素");
        }
        int ret = elem[usedSize - 1];
        return ret;
    }
    public boolean isEmpty(){
        return usedSize == 0;
    }
    public int peek(){
        if(isEmpty()){

            throw new EmptuException("没有元素");
        }
        return elem[usedSize - 1];
    }
}
